<?php
class gallery extends Div
{
	function gallery()
	{
		global $news;
		global $photo;
        global $page;
		$newsData = $news->listLast(null, $_SESSION['sectionId']);
		if ($newsData)
		{
			foreach ($newsData as $line => $info)
			{
				$body .= $info['news'];
				$title = $info['title'];
			}
		}
        $info['imgPath']    = $_REQUEST['image'];
        $info['imgMsg']     = $photo->getImageDescription($info['imgPath']) ;

        if ( !$info['imgPath'] )
        {
            $newsFields = getThemeContent('gallery.html', $info);
		    $page->addJsCode( toJSArray(listImages(GALLERYPATH),'fileData') );
		    $page->addJsCode( $photo->getJsPhotoData() );
		    $page->onLoad("changePhoto('first');");
        }
        else
        {
            $info['title'] = $info['imgMsg'] ? $info['imgMsg'] : $info['title'];
            $newsFields = getThemeContent('gallery_image.html', $info);
        }
		parent::div('gallery', $newsFields);
	}
}
?>
